]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
[StBoxLayout] Implement raise and lower
authorColin Walters <walters@verbum.org>
Fri, 23 Oct 2009 14:18:35 +0000 (10:18 -0400)
committerColin Walters <walters@verbum.org>
Wed, 4 Nov 2009 21:47:11 +0000 (16:47 -0500)
Code copied from ClutterGroup.

https://bugzilla.gnome.org/show_bug.cgi?id=599442

src/st/st-box-layout.c

index 180d893c4fcd9fb5d38f8f3199893549e9350698..12b15081ab9d6c960ae0f4ae603ca4a3502f9e6d 100644 (file)
  *
  */
 
+/* Portions copied from Clutter:
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Authored By Matthew Allum  <mallum@openedhand.com>
+ *
+ * Copyright (C) 2006 OpenedHand
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ */
+
 /**
  * SECTION:st-box-layout
  * @short_description: a layout container arranging children in a single line
@@ -294,8 +308,42 @@ st_box_container_lower (ClutterContainer *container,
                         ClutterActor     *actor,
                         ClutterActor     *sibling)
 {
-  /* XXX: not yet implemented */
-  g_warning ("%s() not yet implemented", __FUNCTION__);
+  StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (container)->priv;
+
+  /* copied from clutter/clutter/clutter-group.c */
+
+  priv->children = g_list_remove (priv->children, actor);
+
+  /* Push to bottom */
+  if (!sibling)
+    {
+      GList *last_item;
+
+      last_item = g_list_first (priv->children);
+
+      if (last_item)
+       sibling = last_item->data;
+
+      priv->children = g_list_prepend (priv->children, actor);
+    }
+  else
+    {
+      gint pos;
+
+      pos = g_list_index (priv->children, sibling);
+
+      priv->children = g_list_insert (priv->children, actor, pos);
+    }
+
+  /* See comment in group_raise for this */
+  if (sibling &&
+      clutter_actor_get_depth (sibling) != clutter_actor_get_depth (actor))
+    {
+      clutter_actor_set_depth (actor, clutter_actor_get_depth (sibling));
+    }
+
+  if (CLUTTER_ACTOR_IS_VISIBLE (container))
+    clutter_actor_queue_redraw (CLUTTER_ACTOR (container));
 }
 
 static void
@@ -303,8 +351,47 @@ st_box_container_raise (ClutterContainer *container,
                         ClutterActor     *actor,
                         ClutterActor     *sibling)
 {
-  /* XXX: not yet implemented */
-  g_warning ("%s() not yet implemented", __FUNCTION__);
+  StBoxLayoutPrivate *priv = ST_BOX_LAYOUT (container)->priv;
+
+  priv->children = g_list_remove (priv->children, actor);
+
+  /* copied from clutter/clutter/clutter-group.c */
+
+  /* Raise at the top */
+  if (!sibling)
+    {
+      GList *last_item;
+
+      last_item = g_list_last (priv->children);
+
+      if (last_item)
+       sibling = last_item->data;
+
+      priv->children = g_list_append (priv->children, actor);
+    }
+  else
+    {
+      gint pos;
+
+      pos = g_list_index (priv->children, sibling) + 1;
+
+      priv->children = g_list_insert (priv->children, actor, pos);
+    }
+
+  /* set Z ordering a value below, this will then call sort
+   * as values are equal ordering shouldn't change but Z
+   * values will be correct.
+   *
+   * FIXME: optimise
+   */
+  if (sibling &&
+      clutter_actor_get_depth (sibling) != clutter_actor_get_depth (actor))
+    {
+      clutter_actor_set_depth (actor, clutter_actor_get_depth (sibling));
+    }
+
+  if (CLUTTER_ACTOR_IS_VISIBLE (container))
+    clutter_actor_queue_redraw (CLUTTER_ACTOR (container));
 }
 
 static void